<template>
  <div class="admission-container">
    <!-- 主体内容 -->
    <main class="content-wrapper">
      <!-- 页面标题 -->
      <div class="page-header">
        <h1>山河大学招生信息</h1>
        <p>欢迎报考山河大学，请选择您希望入学的年级</p>
      </div>
      <p>
        我们的招生政策注重学生的成长和发展，各个年级的学生都可以通过考试后加入山河大学虚拟院校。
      </p>
      <!-- 学制阶段卡片模块 -->
      <section class="education-stage">
        <h3 class="section-title">请选择学制阶段和年级，参加入学考试吧</h3>
        
        <div class="stage-cards">
          <div class="stage-card" 
               :class="{ 'selected': selectedStage === 'primary' }"
               @click="selectStage('primary')">
            <div class="stage-icon">🏫</div>
            <h4 class="stage-title">小学部</h4>
            <p class="stage-desc">六年制基础教育</p>
          </div>
          
          <div class="stage-card" 
               :class="{ 'selected': selectedStage === 'junior' }"
               @click="selectStage('junior')">
            <div class="stage-icon">🏢</div>
            <h4 class="stage-title">初中部</h4>
            <p class="stage-desc">三年制初中教育</p>
          </div>
          
          <div class="stage-card" 
               :class="{ 'selected': selectedStage === 'senior' }"
               @click="selectStage('senior')">
            <div class="stage-icon">🏬</div>
            <h4 class="stage-title">高中部</h4>
            <p class="stage-desc">三年制高中教育</p>
          </div>
          
          <div class="stage-card" 
               :class="{ 'selected': selectedStage === 'college' }"
               @click="selectStage('college')">
            <div class="stage-icon">🏛️</div>
            <h4 class="stage-title">大学部</h4>
            <p class="stage-desc">本科四年制教育</p>
          </div>
        </div>
      </section>
      
      <!-- 年级选择模块 -->
      <section v-if="selectedStage" class="grade-selection">
        <h3 class="section-title">选择年级</h3>
        
        <div class="grade-options">
          <button v-for="grade in availableGrades" 
                  :key="grade.value"
                  :class="{ 'selected': selectedGrade === grade.value }"
                  @click="selectGrade(grade.value)" 
                  class="grade-button">
            {{ grade.label }}
          </button>
        </div>
      </section>
      
      <!-- 进入考试按钮 -->
      <div v-if="selectedStage && selectedGrade" class="exam-action">
        <button class="enter-exam-btn" @click="enterExam">
          进入考试
        </button>
      </div>
    </main>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';

// 向容器页面发送“切换到考试组件”的请求
const emit = defineEmits(['changeComponent']);

// 学制阶段选择状态
const selectedStage = ref('');
const selectedGrade = ref('');

// 根据学制阶段提供对应的年级选项
const availableGrades = computed(() => {
  switch (selectedStage.value) {
    case 'primary':
      return [
        { label: '小学一年级', value: 'primary-1' },
        { label: '小学二年级', value: 'primary-2' },
        { label: '小学三年级', value: 'primary-3' },
        { label: '小学四年级', value: 'primary-4' },
        { label: '小学五年级', value: 'primary-5' },
        { label: '小学六年级', value: 'primary-6' }
      ];
    case 'junior':
      return [
        { label: '初中一年级', value: 'junior-1' },
        { label: '初中二年级', value: 'junior-2' },
        { label: '初中三年级', value: 'junior-3' }
      ];
    case 'senior':
      return [
        { label: '高中一年级', value: 'senior-1' },
        { label: '高中二年级', value: 'senior-2' },
        { label: '高中三年级', value: 'senior-3' }
      ];
    case 'college':
      return [
        { label: '大学一年级', value: 'college-1' },
        { label: '大学二年级', value: 'college-2' },
        { label: '大学三年级', value: 'college-3' },
        { label: '大学四年级', value: 'college-4' }
      ];
    default:
      return [];
  }
});

// 选择学制阶段
const selectStage = (stage) => {
  selectedStage.value = stage;
  selectedGrade.value = ''; // 重置年级选择
};

// 选择年级
const selectGrade = (grade) => {
  selectedGrade.value = grade;
};

// 进入考试 - 只发送事件，不使用路由跳转
const enterExam = () => {
  // 传递必要的参数给父组件
  emit('changeComponent', {
    target: 'exam',
    params: {
      stage: selectedStage.value,
      grade: selectedGrade.value
    }
  });
};
</script>

<style scoped>
/* 主容器样式 */
.admission-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f5f7fa;
}

/* 内容区域样式 */
.content-wrapper {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* 页面标题样式 */
.page-header {
  text-align: center;
}

.page-header h1 {
  font-size: 36px;
  color: #2c3e50;
  margin-bottom: 15px;
  font-weight: 700;
}

.page-header p {
  font-size: 18px;
  color: #7f8c8d;
}

/* 选择提示样式 */
.selection-prompt {
  text-align: center;
  margin-bottom: 50px;
  padding: 30px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.selection-prompt h2 {
  font-size: 28px;
  color: #3498db;
  margin-bottom: 10px;
}

.selection-prompt p {
  font-size: 16px;
  color: #7f8c8d;
}

/* 区块标题样式 */
.section-title {
  font-size: 24px;
  color: #2c3e50;
  margin-bottom: 25px;
  text-align: center;
}

/* 学制阶段卡片样式 */


.stage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.stage-card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.stage-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  border-color: #3498db;
}

.stage-card.selected {
  border-color: #2ecc71;
  background-color: #f1f9f4;
}

.stage-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.stage-title {
  font-size: 22px;
  color: #2c3e50;
  margin-bottom: 10px;
  font-weight: 600;
}

.stage-desc {
  font-size: 14px;
  color: #7f8c8d;
}

/* 年级选择样式 */
.grade-selection {
  margin-bottom: 20px;
}

.grade-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
}

.grade-button {
  padding: 12px 24px;
  background-color: #fff;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.3s ease;
}

.grade-button:hover {
  border-color: #3498db;
  color: #3498db;
}

.grade-button.selected {
  background-color: #3498db;
  border-color: #3498db;
  color: #fff;
}

/* 进入考试按钮样式 */
.exam-action {
  text-align: center;
  margin-top: 20px;
}

.enter-exam-btn {
  padding: 16px 48px;
  background-color: #2ecc71;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.enter-exam-btn:hover {
  background-color: #27ae60;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(46, 204, 113, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header h1 {
    font-size: 28px;
  }
  
  .selection-prompt h2 {
    font-size: 24px;
  }
  
  .section-title {
    font-size: 20px;
  }
  
  .stage-cards {
    grid-template-columns: 1fr;
  }
  
  .enter-exam-btn {
    padding: 14px 36px;
    font-size: 16px;
  }
}
</style>